Skip to content

fix: Add inline editing (Followup)#88722

Closed
mohammadjafarinejad wants to merge 5 commits intoExpensify:mainfrom
mohammadjafarinejad:fix/82534-followup
Closed

fix: Add inline editing (Followup)#88722
mohammadjafarinejad wants to merge 5 commits intoExpensify:mainfrom
mohammadjafarinejad:fix/82534-followup

Conversation

@mohammadjafarinejad
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad mohammadjafarinejad commented Apr 24, 2026

Explanation of Change

This PR is a follow-up to fix deploy blockers related to the inline editing feature.

Fixed Issues

$ #88711
#82534
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@mohammadjafarinejad mohammadjafarinejad requested review from a team as code owners April 24, 2026 14:13
@melvin-bot melvin-bot Bot requested review from JmillsExpensify and ahmedGaber93 and removed request for a team April 24, 2026 14:13
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 24, 2026

@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team April 24, 2026 14:13
@mohammadjafarinejad mohammadjafarinejad marked this pull request as draft April 24, 2026 14:15
mohammadjafarinejad and others added 2 commits April 24, 2026 18:20
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/MoneyRequestAmountInput.tsx 74.07% <ø> (ø)
src/components/NumberWithSymbolForm.tsx 48.92% <ø> (ø)
src/components/Table/EditableCell/EditableCell.tsx 33.33% <100.00%> (+3.92%) ⬆️
...ts/TextInputWithSymbol/BaseTextInputWithSymbol.tsx 100.00% <100.00%> (ø)
src/styles/index.ts 48.95% <ø> (ø)
...ponents/TransactionItemRow/DataCells/TotalCell.tsx 83.33% <66.66%> (-7.98%) ⬇️
src/libs/actions/TransactionInlineEdit.ts 22.78% <0.00%> (-0.90%) ⬇️
... and 21 files with indirect coverage changes

Co-authored-by: Copilot <copilot@github.com>
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 24, 2026

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

Co-authored-by: Copilot <copilot@github.com>
@ahmedGaber93
Copy link
Copy Markdown
Contributor

Investigate some issue with Melvin until new PR is opened

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@MelvinBot Can you add a proposal here (in this PR discussion) for this issue #88737?

@MelvinBot
Copy link
Copy Markdown
Contributor

Proposal for #88737

Scan - Merchant field shows "Scanning..." text when editing inline

What is the root cause of that problem?

getMerchantName() replaces the raw merchant value with the translated "Scanning..." string for scanning transactions. This display-only string is then passed as the initial editable value to MerchantOrDescriptionCell, which feeds it into useInlineEditState as the text input's initial value. So when the user clicks to edit inline, the input is pre-filled with "Scanning...".

The RHP doesn't have this problem because it reads the raw transaction merchant ('(none)'/PARTIAL_TRANSACTION_MERCHANT), detects it as invalid via isInvalidMerchantValue(), and initializes the input with an empty string instead.

What changes do you think we should make in order to solve the problem?

In TransactionItemRow, when the transaction isScanning, pass an empty string as the editable merchant value to MerchantOrDescriptionCell while keeping the "Scanning..." display text. This can be done by passing the raw (non-display-formatted) merchant through isInvalidMerchantValue() the same way the RHP does, so the edit input initializes with '' instead of "Scanning...".

Alternatively, disable inline merchant editing entirely while isScanning is true (set canEditMerchant to false), since SmartScan is actively populating the field.

What alternative solutions did you explore?

  • Sanitizing inside useInlineEditState — rejected because it would require locale-aware string comparison and is the wrong abstraction layer for this fix.
  • Checking in MerchantOrDescriptionCell directly — possible but less clean than fixing at the source in TransactionItemRow where the display vs edit value split should happen.

Note: This proposal was originally posted on Expensify/App#88737. The issue has since been closed after inline editing was reverted. This fix should be applied when re-introducing inline editing.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

Alternatively, disable inline merchant editing entirely while isScanning is true (set canEditMerchant to false), since SmartScan is actively populating the field.

@MelvinBot implement that on this PR

Note: we should do the same for input amount since it also display scanning...

@MelvinBot
Copy link
Copy Markdown
Contributor

To disable inline editing for merchant and amount while scanning, the changes needed are in TransactionItemRow/index.tsx:

  1. Merchant: Set canEditMerchant to false when isScanning is true
  2. Amount/Total: Set canEditTotal to false when isScanning is true

This prevents the "Scanning..." placeholder from appearing as editable text in both fields.


⚠️ I can't push changes to this PR because I didn't open it and I'm not listed as an assignee. To have me make this fix, add me to the PR assignees and then retry your request.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@MelvinBot add proposal here for #88657

@MelvinBot
Copy link
Copy Markdown
Contributor

Proposal for Expensify/App#88657

Expense - Significant delay to show Popover of category or date

What is the root cause of that problem?

usePopoverEditState.startEditing() defers popover opening via InteractionManager.runAfterInteractions(). This means the popover will not open until all outstanding interaction handles are cleared.

When the user dismisses a popover (clicks outside), ReanimatedModal creates an interaction handle for the close animation. That handle is only cleared in onCloseCallBack after the animation completes. If the user scrolls between closing and re-clicking, scroll event processing and FlashList cell recycling can delay the animation callback — or worse, unmount the cell before the handle is cleared, leaving an orphaned handle that blocks the runAfterInteractions queue indefinitely.

What changes do you think we should make in order to solve the problem?

Replace InteractionManager.runAfterInteractions in usePopoverEditState.startEditing() with a simpler deferral mechanism that doesn't depend on the global interaction handle queue. For example, use requestAnimationFrame (or two stacked requestAnimationFrame calls to ensure a layout pass) to defer openPopover(). The original comment says the deferral is only needed so that "the anchor is measured correctly" — this doesn't require waiting for all modal animations to complete, just a single layout cycle.

const startEditing = () => {
    setIsEditing(true);
    // Defer opening until next frame so the anchor is measured correctly
    requestAnimationFrame(() => {
        openPopover();
    });
};

This eliminates the dependency on the ReanimatedModal close animation's interaction handle lifecycle entirely.

What alternative solutions did you explore?

  • Ensure interaction handles are always cleared on unmountReanimatedModal already has cleanup logic, but FlashList recycling can cause unmount timing issues. This would be a more defensive fix but harder to guarantee across all scroll/recycling scenarios.
  • Add a timeout fallback to runAfterInteractions — e.g., setTimeout(openPopover, 300) as a safety net. This is fragile and doesn't address the root cause.
  • Disable inline editing during scroll — unnecessarily restrictive and doesn't fix the underlying interaction handle issue.

Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@MelvinBot add proposal here for #88652

@MelvinBot
Copy link
Copy Markdown
Contributor

Proposal for #88652

Expense - Merchant cannot be cleared by inline editing

What is the root cause of that problem?

editTransactionMerchantInline calls isInvalidMerchantValue() which treats empty string as invalid and returns early without calling updateMoneyRequestMerchant. This blocks clearing the merchant for all transaction types — including unreported self-DM expenses where clearing the merchant is a valid operation.

After the silent rejection, useInlineEditState.save() resets localValue back to the original value (line 38), so the UI reverts as if nothing happened.

The existing non-inline editing path (updateMoneyRequestMerchant) accepts empty strings without issue, so the backend supports this operation — only the inline guard blocks it.

What changes do you think we should make in order to solve the problem?

In editTransactionMerchantInline, relax the guard to allow empty merchant strings for unreported expenses. The params object already contains the transaction and report context needed to determine whether the expense is unreported. Specifically:

  1. Pass the transaction/report context into the guard check.
  2. Only block empty merchant for reported/submitted expenses (where merchant is required), and allow it for unreported expenses (self-DM without workspace merchant requirements).

This aligns with the RHP editing behavior and the comment from trjExpensify on the issue: "selfDM without a workspace can be used without merchant requirements, so it probably makes sense to follow the merchant field restriction that allows it to be blank when unreported."

What alternative solutions did you explore?

  • Removing the isInvalidMerchantValue guard entirely — rejected because it could allow clearing merchant on reported expenses where merchant is required, which would match Classic's behavior of blocking empty merchant but could cause data integrity issues.
  • Moving the guard into useInlineEditState — rejected because the hook is generic and shouldn't contain merchant-specific business logic.
  • Disabling the edit button when merchant is empty — doesn't apply here since the user is trying to clear an existing merchant value, not edit an empty one.

Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad I investigate another fix instead of editusePolicyForTransaction here #88715 (comment) which will fix those

We will use the entire policy in the useTransactionInlineEdit function.

    const [completePolicy] = originalUseOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(policyID)}`);

Then pass it here policy: completePolicy ?? policy,


#88722 (comment) LGTM for #88737

#88722 (comment) LGTM for #88657

@ahmedGaber93
Copy link
Copy Markdown
Contributor

Fix for #88652

edit editTransactionMerchantInline to be:

/** Updates the merchant of an expense from the Search results table or the Expense Report page. */
function editTransactionMerchantInline(params: TransactionInlineEditParams, newMerchant: string) {
    const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${params.transactionID}`];
    const isUnreportedTransaction = isExpenseUnreported(transaction);
    const isClearingMerchant = newMerchant === '';
    const isInvalidMerchantForUpdate = isInvalidMerchantValue(newMerchant) && !(isUnreportedTransaction && isClearingMerchant);

    if (isInvalidMerchantForUpdate) {
        return;
    }
    const iouParams = getIouParamsForTransaction(params);
    updateMoneyRequestMerchant({
        ...iouParams,
        value: newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
        hash: params.hash,
    });
}

@ahmedGaber93
Copy link
Copy Markdown
Contributor

Fix for #88748

Disable category editing when shouldSelectPolicy is true

Changes

pass shouldSelectPolicy to getTransactionEditPermissions

    const isPerDiem = isPerDiemRequest(transaction);
    const {shouldSelectPolicy} = usePolicyForMovingExpenses(isPerDiem);
    
getTransactionEditPermissions({
   ...,
   shouldSelectPolicyForUnreported: shouldSelectPolicy
});
    

canEditCategory will be:

-        canEditCategory:
-            (isPolicyExpenseChat && (!!categoryForDisplay || hasEnabledOptions(policyCategories ?? {}))) || (isUnreported && (!policy || hasEnabledOptions(policyCategories ?? {}))),
+        canEditCategory:
+            (isPolicyExpenseChat && (!!categoryForDisplay || hasEnabledOptions(policyCategories ?? {}))) ||
+            // For unreported expenses, disable inline category editing while workspace selection is required.
+            (isUnreported && !shouldSelectPolicyForUnreported && hasEnabledOptions(policyCategories ?? {})),

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@MelvinBot add proposal here for #88640 (comment)

@MelvinBot
Copy link
Copy Markdown
Contributor

Proposal for #88640

Report - Amount field accepts 0 amount in IOU expense when inline editing

What is the root cause of that problem?

The inline amount editing path lacks the zero-amount validation that the RHP already has. Specifically:

  1. TotalCell.handleAmountSave checks parsedValue >= 0, which allows 0 through.
  2. editTransactionAmountInline only guards against negative amounts (newAmount < 0), not zero.

Meanwhile, the RHP correctly rejects zero amounts for P2P requests via isAmountInvalid(), which blocks amounts below 0.01 for REQUEST/SUBMIT on P2P reports and for PAY/INVOICE/SPLIT types. This validation was never replicated in the inline edit path introduced by PR #83127.

What changes do you think we should make in order to solve the problem?

Add a zero-amount guard in editTransactionAmountInline. The function already receives params which includes parentReport. Use isIOUReport(params.parentReport) to determine if the expense is P2P, and reject newAmount === 0 (or < 1 in backend amount units) in that case — mirroring the logic in isAmountInvalid().

This is the correct layer for the fix because all inline amount edits flow through this action, making it a single point of enforcement.

What alternative solutions did you explore?

  • Changing parsedValue >= 0 to parsedValue > 0 in TotalCell.handleAmountSave — simpler but would block zero amounts for all report types, including expense reports where zero may be valid.
  • Replicating the full isAmountInvalid() check in TotalCell — rejected because it would require threading IOU type and P2P context into a UI component that shouldn't own business logic.

Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

Fix for #88640

function editTransactionAmountInline(params: TransactionInlineEditParams, newAmount: number) {
-   if (newAmount < 0) {
+   if (newAmount < 0 || (newAmount === 0 && isIOUReport(params.parentReport))) {
        return;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants